package org.ipower.financial.service.impl;

import ipower.configuration.ModuleDefineCollection;
import ipower.configuration.ModuleSystem;
import ipower.configuration.ModuleSystemCollection;
import ipower.utils.ResUtil;

import java.io.IOException;
import java.io.InputStream;

import org.ipower.financial.service.ModuleService;
/**
 * 模块服务实现类。
 * @author young。
 * @since 2013-09-01。
 * */
public class ModuleServiceImpl implements ModuleService {
	
	@Override
	public ModuleDefineCollection LoadModules(String systemId) {
		if(systemId == null || systemId.isEmpty()) return null;
		try {
			InputStream is = ResUtil.loadResourceStream("config", "ModuleFile");
			if(is != null){
				ModuleSystemCollection systems = ModuleSystemCollection.parse(is);
				if(systems != null && systems.size() > 0){
					ModuleSystem ms = systems.item(systemId);
					if(ms != null) return ms.getModules();
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return null;
	}

}